#include<stdio.h>
/*int main()
{
    double C,F;
    scanf("%lf", &F);
    C=5*(F-32)/9;
    printf("%.5lf", C);
    return 0;
}*/
/*#include<math.h>
int main()
{
    double a;
    scanf("%lf",&a);
    if(a < 0)
    {
        printf("%.0lf", ceil(a));
    }
    else
    {
        printf("%.0lf", a);
    }
    return 0;
}*/



/*#include<stdio.h>
int main()
{
    int a;
    scanf("%d",&a);
    bool b = a;
    int c = b;
    printf("%d", c);
    return 0;
}*/



#include<stdio.h>
int main()
{
    int arr[5],eat=0;
    for(int i = 0; i < 5; i++)
    {
        scanf("%d",&arr[i]);
    }
    for(int i = 0; i < 5; i++)
    {
    	eat += arr[i] % 3;
        if(i==0)
        {
            
            arr[i+1] += arr[i] / 3;
            arr[i-1+5] += arr[i] / 3;
            arr[i] /= 3;
        }
        else if(i==4)
        {
            arr[(i+1)%5] += arr[i] / 3;
            arr[i-1] += arr[i] / 3;
            arr[i] /= 3;
        }
        else
        {
        	arr[i+1] += arr[i] / 3;
        	arr[i-1] += arr[i] / 3;
        	arr[i] /= 3;
		}
        
    }
    for(int i = 0; i < 5; i++)
    {
        printf("%d ",arr[i]);
    }
    printf("\n");
    printf("%d", eat);
    return 0;
}

